package com.emode.action;

import java.io.File;
import java.io.IOException;

import com.emode.base.BaseAction;
import com.emode.entity.Upfile;
import com.emode.util.FileUtil;
import com.emode.util.StringUtils;


public class UpfileAction extends BaseAction<Upfile> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2726744086893857838L;
	/*
	 * 创建工具
	 */
	private String fileFileName;
	private String key;
	private File file;

	public String uplaodFile() throws Exception{
		String photopath = "upload\\avatar\\";
		if(!StringUtils.isBlank(fileFileName)){
			key = fileFileName;
			String filePath = FileUtil.fileCopy(file, fileFileName,photopath);
			filePath = filePath.replace("\\", "/");
			filePath = FileUtil.getWebRootPath()+filePath;
			fileservice.upload(key, filePath);
		}
		
		return "succ";
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	
	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	public String getFileFileName() {
		return fileFileName;
	}

	public void setFileFileName(String fileFileName) {
		this.fileFileName = fileFileName;
	}
	


	
}
